package cn.edu.zafu.bigdata.Yum;

import java.util.HashMap;
import java.util.List;

public class StudentGradeManager {
    HashMap<String,Integer> hashMap;

    public StudentGradeManager() {
        hashMap=new HashMap<>();
    }

    public void addStudent(String name, int grade){
        hashMap.put(name,grade);
    }
    public int getGrade(String name){
        return hashMap.getOrDefault(name,-1);
    }
    public void removeStudent(String name){
        hashMap.remove(name);
    }
    @Override
    public String toString() {
        return "StudentGradeManager{" +
                "hashMap=" + hashMap +
                '}';
    }
}
class TestSGM{
    public static void main(String[] args) {
        List<Integer> Glist = List.of(78,98,83,90,33,64);
        List<String> Nlsit = List.of("fxc","hy","sch","zbw","hzq","mmm");
        int n=Glist.size();
        StudentGradeManager SGM=new StudentGradeManager();
        for(int i=0; i<n ; i++){
            SGM.addStudent(Nlsit.get(i),Glist.get(i));
        }
        System.out.println("添加信息完成后的hashMap:");
        System.out.println(SGM.toString());
        System.out.println("利用getGrade方法找到sch的成绩为："+SGM.getGrade("sch"));
        SGM.removeStudent("hy");
        System.out.println("利用removeStudent方法移除hy信息后的hashMap:");
        System.out.println(SGM.toString());
    }
}